<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>组织生活申报</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#checkAll").on('click', function() {
				//复选框
				var ch = this.checked;
				if (ch) {
					$("input[name='ids']").prop("checked", true);
				} else {
					$("input[name='ids']").prop("checked", false);
				}
			});
			getCheckList = function() {
				var ids = [];
				$("input[name='ids']:checked").each(function() {
					ids.push($(this).val());
				});
				return ids;
			}
			
			$("#btnAdd").click(function(){
				
				$.ajax({
					type : 'POST',
					url : "${ctx}/life/organizeLife/checkOrgSatate",
					type : "get",
					dataType : "json",
					async : false,//同步  
					success : function(result) {		
						if(result.type == "success"){
							$("#searchForm").attr("action","${ctx}/life/organizeLifeJh/form");
							$("#searchForm").submit();
						} else {
							top.$.jBox.error("当前支部未开通！","系统提示",function(v,h,f){
							
							},{buttonsFocus:1});
							top.$('.jbox-body .jbox-icon').css('top','55px');
														
						}
					}
				});							
			});
					
		$("#btnTj").on('click', function() {
			$.ajax({
				type : 'POST',
				url : "${ctx}/life/organizeLife/checkOrgSatate",
				type : "get",
				dataType : "json",
				async : false,//同步  
				success : function(result) {		
					if(result.type == "success"){
						
						var ids = getCheckList();
						if (ids.length < 1) {
							alert("请选择一条记录进行提交");
							return false;
						}
						$.ajax({
							type : 'POST',
							url : "${ctx}/life/organizeLifeJh/organizeLifeTj/" + ids,
							type : "get",
							dataType : "json",
							async : false,//同步  
							success : function(result) {		
								if(result.type == "success"){
									
									top.$.jBox.confirm("组织生活提交成功！","系统提示",function(v,h,f){
										if(v=="ok"){
										    window.location.reload();//刷新当前页面.

										}
									},{buttonsFocus:1});
									top.$('.jbox-body .jbox-icon').css('top','55px');
								} else {
									$.jBox.info("组织生活提交失败！");
								}
							}
						});
					}else{
						top.$.jBox.error("当前支部未开通！","系统提示",function(v,h,f){
						},{buttonsFocus:1});
						top.$('.jbox-body .jbox-icon').css('top','55px');
					}	
			 }
		         });
		     });
		});
		function page(n, s) {
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
			return false;
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a>组织生活申报</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="organizeLife" action="${ctx}/life/organizeLifeJh/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
				<input type="hidden" name="ids" id="ids">
		
           <ul class="ul-form">
		    <li><label>活动名称：</label>
				<form:input path="lifename" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li><label style="margin-left: -20px;">分类：</label>
				<form:select path="typeids" class="input-medium" >
							<form:option value="" label="全部"/>
							<form:options items="${organizeLifeTypes}" itemLabel="typename" itemValue="id" htmlEscape="false"/>
						</form:select>
			</li>
			
			
			
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<shiro:hasPermission name="life:organizeLifeJh:edit"><li class="btns">
			<input id="btnAdd" class="btn btn-primary" type="submit" value="创建"/></li>
			</shiro:hasPermission>
			<li class="btns"><input id="btnTj" class="btn btn-primary" type="button" value="提交"/></li>
			
			
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
			<th width="2%" style='text-align: center'><input
					type="checkBox" id="checkAll" /></th>
				<th style="width:3%">序号</th>
				<th style="width:35%">活动名称</th>
				<th style="width:15%">分类</th>
				<th style="width:5%">计划状态</th>
				<th style="width:10%">计划时间</th>	
				<th style="width:15%">活动地点</th>
				<shiro:hasPermission name="life:organizeLifeJh:edit"><th style="width:10%">操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="organizeLife" varStatus="rowIndex">
			<tr>
			    <td style='text-align: center'><input type='checkbox' id='ids' name='ids' value='${organizeLife.id}' /></td>
				<td style='text-align: center'>${rowIndex.index+1}</td>	
				<td>${organizeLife.lifename}</td>
				<td>
					<div style="width:200px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;" 
					title="${organizeLife.typeids}">${organizeLife.typeids}</div>
				</td>
				<td style='text-align: center'>
					${fns:getDictLabel(organizeLife.jhstate, 'life_state_flag', '')}
				</td>
				<td style='text-align: center'>
					<fmt:formatDate value="${organizeLife.jhtime}" pattern="yyyy-MM-dd HH:mm"/>
				</td>
				<td>
				<div style="width:150px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;" 
					title="${organizeLife.adress}">${organizeLife.adress}</div>
				</td>
				<shiro:hasPermission name="life:organizeLifeJh:edit"><td style='text-align: center'>
    				<a href="${ctx}/life/organizeLifeJh/form?id=${organizeLife.id}">修改</a>
					<a href="${ctx}/life/organizeLifeJh/delete?id=${organizeLife.id}" onclick="return confirmx('确认要删除该组织生活管理吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>